﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Web.Configuration;
using System.Data;


public partial class Admin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
            IspolniMuzei();
    }

    
    protected void IspolniMuzei()
    {
        WebServiceM.Muzei muzei = new WebServiceM.Muzei();

        gd_izmena.DataSource = muzei.VratiMuzei();
        gd_izmena.DataBind(); 
    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        Response.Redirect("Pocetna.aspx");
    }
    protected void btnCisti_Click(object sender, EventArgs e)
    {
        txtID.Text = "";
        txtGrad.Text = "";
        txtMuzej.Text = "";
        txtCena.Text = "";
    }

    protected void gd_pregled_SelectedIndexChanged(object sender, EventArgs e)
    {
        txtID.Text = gd_izmena.SelectedRow.Cells[0].Text;
        txtGrad.Text = gd_izmena.SelectedRow.Cells[1].Text;
        txtMuzej.Text = gd_izmena.SelectedRow.Cells[2].Text;
        txtCena.Text = gd_izmena.SelectedRow.Cells[3].Text;

    }
    protected void btnIzmeni_Click(object sender, EventArgs e)
    {
        if (gd_izmena.SelectedIndex != -1)
        {
            WebServiceM.Muzej muz = new WebServiceM.Muzej();
            muz.id_m = gd_izmena.SelectedRow.Cells[0].Text;
            muz.grad = txtGrad.Text;
            muz.muzej = txtMuzej.Text;
            muz.cena = txtCena.Text;
            WebServiceM.Muzei muzeiService = new WebServiceM.Muzei();
            if (muzeiService.PromeniMuzej(muz))
                IspolniMuzei();
        }
    }
    protected void btnDodadi_Click(object sender, EventArgs e)
    {
        
            WebServiceM.Muzej m = new WebServiceM.Muzej();
            m.id_m = txtID.Text;
            m.grad = txtGrad.Text;
            m.muzej = txtMuzej.Text;
            m.cena = txtCena.Text;
            WebServiceM.Muzei muzeiS = new WebServiceM.Muzei();

                if (muzeiS.DodajMuzej(m))
                    IspolniMuzei();
           
        
    }
    protected void btnBrisi_Click(object sender, EventArgs e)
    {
        if (gd_izmena.SelectedIndex != -1)
        {
            WebServiceM.Muzej m = new WebServiceM.Muzej();
            m.id_m = gd_izmena.SelectedRow.Cells[0].Text;
            WebServiceM.Muzei a = new WebServiceM.Muzei();
            if (a.BrisiMuzej(m))
                IspolniMuzei();
        }
    }
}